#ifndef _DSWWANMSGSESSION_H
#define _DSWWANMSGSESSION_H
#include <libdswsession/dswmsgsession_base.h>

class CDswwanmsgsession : public CDswmsgsession_base
{
public:
	CDswwanmsgsession(EN_MISSION_TYPE nType, LPST_ENV_T pEnv, char* pHost, int nPort);
	virtual ~CDswwanmsgsession();
public:
	void UpdateHost(char * pHost, int nPort);
protected:
	virtual void OnError(struct bufferevent *bev, short events);
	virtual void OnConnect(struct bufferevent *bev, short events);
	virtual int MakePayloadLength(char* pData, int nLen);
	virtual void SendMsg(char * pMsg);
	virtual bool GetPUCID(char * pMsg);
	virtual void ProcessBody(char* pMsg);
	virtual void AddP2PMsgSession(CMarkup &xml);

	virtual int OnMessage(EN_MSG_TYPE nMsgType, void * pParam);
private:
	static void cbHeartBeatTask(int fd, short events, void* ctx){((CDswwanmsgsession*)ctx)->HeartBeatTask(fd, events);};
	void HeartBeatTask(int fd, short events);
protected:
	virtual bool DealTCPP2PResp(char* pCId, void* pMsgReq, const char* pMsgIDResp){return true;};
	virtual bool DealRegisterToP2PServer(char* pCId, void* pMsgReq, const char* pMsgIDResp);
	virtual bool DealHeartResp(char* pCId, void* pMsgReq, const char* pMsgIDResp);
	virtual bool DealGetPUAV2Req(char* pCId, void* pMsgReq, const char* pMsgIDResp);
	virtual bool DealStartStreamV2Req(char* pCId, void* pMsgReq, const char* pMsgIDResp);
	virtual bool DealStopStreamV2Req(char* pCId, void* pMsgReq, const char* pMsgIDResp);
	virtual bool DealStartTransStreamReq(char* pCId, void* pMsgReq, const char* pMsgIDResp);
	virtual bool DealStopTransStreamReq(char* pCId, void* pMsgReq, const char* pMsgIDResp);
	virtual bool DealSetParamReq(char* pCId, void* pMsgReq, const char* pMsgIDResp);
private:
	EN_MISSION_TYPE m_nMissionType;
	ST_TIMER_PARAM_T m_nHeartBeatTask;
	char m_sWanIp[64], m_sPUCID_from_pug[64], m_sPUCID_from_puc[64];
	char* m_pSendBuffer;
	ST_DEVICE_BASE_T m_nBasicParam;
};

#endif

